import { Model, ClientSession } from 'mongoose';
import mongoose from 'mongoose';

export interface ICard {
    cardId: string;
    title: string;
    content: string;
    listId: string;
    order: number;
    createdAt: number;
    updatedAt: number;
    version: number;
}
export interface ICardModel extends Model<ICard> {
    updateOrderForBackwardMove(listId: string, oldOrder: number, newOrder: number): Promise<unknown>;
    updateOrderForForwardMove(listId: string, oldOrder: number, newOrder: number): Promise<unknown>;
    generateNextOrder(): Promise<number>;
    createCardWithTransaction(title: string, content: string, listId: string): Promise<ICard>;
    startSession(): Promise<ClientSession>;
}

export interface ICardList {
    listId: string;
    title: string;
    order: number;
    createdAt: number;
    version: number;
}
export interface ICardListModel extends Model<ICardList> {
    updateOrderForBackwardMove(listId: string, oldOrder: number, newOrder: number): Promise<unknown>;
    updateOrderForForwardMove(listId: string, oldOrder: number, newOrder: number): Promise<unknown>;
    generateNextOrder(): Promise<number>;
    createCardListWithTransaction(title: string, listId: string): Promise<ICardList>;
    startSession(): Promise<ClientSession>;
}

export interface ICheckList {
    checkListId: string;
    cardId: string;
    title: string;
    items: mongoose.Types.ObjectId[];
    createdAt?: number;
    updatedAt?: number;
}
export interface ICheck {
    checkId: string;
    title: string;                  // 清单标题
    createdAt?: number;             // 创建时间
    updatedAt?: number;             // 更新时间
    completed: boolean;             // 是否完成
    completedAt?: number;           // 完成时间
    checkListId: string;
}